Use jQuery on a variable instead on the DOM ? [solved]

Posted by Stef on Stack Overflow See other posts from Stack Overflow or by Stef
Published on 2010-05-07T06:56:34Z Indexed on 2010/05/10 10:44 UTC
Read the original article Hit count: 157

Filed under:
|
|
|
|

In jQuery you can do :

$("a[href$='.img']").each(function(index) {
    alert($(this).attr('href'));
}

I want to write a jQuery function which crawls x-levels from a website and collects all hrefs to gif images.

So when I use the the get function to retrieve another page,

$.get(href, function(data) {

});

I want to be able to do something like

data.$("a[href$='.img']").each(function(index) {
});

Is this possible ?

...UPDATE...

Thanks to the answers, I was able to fix this problem.

function FetchPage(href) {
    $.ajax({
        url: href,
        async: false,
        cache: false,
        success: function(html){
            $("#__tmp__").append("<page><name>" + href + "</name><content>" + html + "</content></page>");
        }
    });
}

See this zip file for an example how to use it.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about variable